
var datagrid = require('datagrid');
var router = require('router');
var request = require('request');
var template = require('template');

return extend('./main', {
    target:'#myQuestion',
    path:'/question/',
    onInit:function(){
        datagrid({
            isBorder:false,
            fields:'id',
            container:this.element.find('.m-message-body'),
            paging:{
                url:sourceHttp
            },
            columns:[{
                title:'',
                width:20,
                content:'',
                style:{
                    border:'none',
                    padding:'0px',
                    background:'#fff'
                }
            }, {
                title:'标题',
                field:'buname',
                align:'left'
            }, {
                title:'提交时间',
                field:'buname',
                align:'left',
                width:'20%'
            }, {
                title:'回复时间',
                field:'buname',
                align:'left',
                width:'20%'
            }, {
                title:'',
                width:20,
                content:'',
                style:{
                    border:'none',
                    padding:'0px',
                    background:'#fff'
                }
            }],
            onRowClick:function(self, e, elem, data){
                var detail = elem.next('.question-detail');
                if(detail.length){
                    detail.toggleClass('f-dn');
                    self.resize()
                }
                else{
                    request.get('user.json', data, {
                        200:function(res){
                            elem.after(template.render(require('../../views/message/questionDetail'), res.data));
                            self.resize()
                        }
                    })
                }
            }
        })
    }
})